package com.example.fw;

import java.util.Set;


public class Groups {

	public Set<GroupObject> groupList;

	public Groups(Set<GroupObject> groupList) {
		this.groupList = groupList;
	}

	public Groups withAdded(GroupObject validGroup) {
		Groups group = new Groups(groupList);
		validGroup.setId("$$$");
		group.groupList.add(validGroup);
		validGroup.setId(null);
		return group;
	}

	public Groups withRemoved(GroupObject validGroup) {
		Groups group = new Groups(groupList);
		group.groupList.remove(validGroup);
		return group;
	}

	@Override
	public String toString() {
		return "Groups [" + groupList + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((groupList == null) ? 0 : groupList.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Groups other = (Groups) obj;
		if (groupList == null) {
			if (other.groupList != null)
				return false;
		} else if (!groupList.equals(other.groupList))
			return false;
		return true;
	}
}
